home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / pyshared / UpdateManager / HelpViewer.py < prev    next >
Text File  |  2009-11-02  |  984b  |  34 lines

  1. # helpviewer.py
  2.  
  3. import os
  4. import subprocess
  5.  
  6. # Hardcoded list of available help viewers
  7. # FIXME: khelpcenter support would be nice
  8. #KNOWN_VIEWERS = ["/usr/bin/yelp", "/usr/bin/khelpcenter"]
  9. KNOWN_VIEWERS = ["/usr/bin/yelp"]
  10.  
  11. class HelpViewer:
  12.     def __init__(self, docu):
  13.         self.command = []
  14.         self.docu = docu
  15.         for viewer in KNOWN_VIEWERS:
  16.             if os.path.exists(viewer):
  17.                 self.command = [viewer, "ghelp:%s" % docu]
  18.                 break
  19.         
  20.     def check(self):
  21.         """check if a viewer is available"""
  22.         if self.command == []:
  23.             return False
  24.         else:
  25.             return True
  26.  
  27.     def run(self):
  28.         """open the documentation in the viewer"""
  29.         # avoid running the help viewer as root
  30.         if os.getuid() == 0 and os.environ.has_key('SUDO_USER'):
  31.             self.command = ['sudo', '-u', os.environ['SUDO_USER']] +\
  32.                            self.command
  33.         subprocess.Popen(self.command)
  34.